﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.Collections;
using WeMakeSP.Platform.SharePoint.Configuration;

namespace WeMakeSP.ImageResizer.Configuration
{
    /// <summary>
    /// Helper class for image resizer 
    /// property bags.
    /// </summary>
    public static class ImageResizerPropertyBags
    {
        #region Public Static Methods

        /// <summary>
        /// Deletes the configurations from web.
        /// </summary>
        /// <param name="web">The web.</param>
        public static void DeleteConfigurationsFromWeb(SPWeb web)
        {
            string prefix =
                PictureLibraryPropertyBag.Prefix;

            SPPropertyBag propertyBag =
                web.Properties;

            ICollection keys =
                propertyBag.Keys;

            SPWebPropertyBag webPropertyBag =
                new SPWebPropertyBag(web);

            foreach (string key in keys)
            {
                if (key.StartsWith(prefix))
                {
                    webPropertyBag.Remove(key);
                }
            }
        }

        #endregion
    }
}
